
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 02/09/2018 13:08:15
-- Generated from EDMX file: D:\HynuIOTA.Web\HynuIOTA.Web\HynuIOTA.Entity\HynuIOTAEntities.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [HynuIOTA];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_UserRelo_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserRelo] DROP CONSTRAINT [FK_UserRelo_User];
GO
IF OBJECT_ID(N'[dbo].[FK_UserRelo_Relo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserRelo] DROP CONSTRAINT [FK_UserRelo_Relo];
GO
IF OBJECT_ID(N'[dbo].[FK_UserAction_User]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserAction] DROP CONSTRAINT [FK_UserAction_User];
GO
IF OBJECT_ID(N'[dbo].[FK_UserAction_Action]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[UserAction] DROP CONSTRAINT [FK_UserAction_Action];
GO
IF OBJECT_ID(N'[dbo].[FK_BlogArticleBlogComment]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BlogComment] DROP CONSTRAINT [FK_BlogArticleBlogComment];
GO
IF OBJECT_ID(N'[dbo].[FK_BlogArticleBlogVisit]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BlogVisit] DROP CONSTRAINT [FK_BlogArticleBlogVisit];
GO
IF OBJECT_ID(N'[dbo].[FK_UserBlogArticle]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BlogArticle] DROP CONSTRAINT [FK_UserBlogArticle];
GO
IF OBJECT_ID(N'[dbo].[FK_UserBlogComment]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BlogComment] DROP CONSTRAINT [FK_UserBlogComment];
GO
IF OBJECT_ID(N'[dbo].[FK_UserNews]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[News] DROP CONSTRAINT [FK_UserNews];
GO
IF OBJECT_ID(N'[dbo].[FK_UserNotice]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Notice] DROP CONSTRAINT [FK_UserNotice];
GO
IF OBJECT_ID(N'[dbo].[FK_BlogArticleTags_BlogArticle]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BlogArticleTags] DROP CONSTRAINT [FK_BlogArticleTags_BlogArticle];
GO
IF OBJECT_ID(N'[dbo].[FK_BlogArticleTags_Tags]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[BlogArticleTags] DROP CONSTRAINT [FK_BlogArticleTags_Tags];
GO
IF OBJECT_ID(N'[dbo].[FK_ChannelNews_Channel]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ChannelNews] DROP CONSTRAINT [FK_ChannelNews_Channel];
GO
IF OBJECT_ID(N'[dbo].[FK_ChannelNews_News]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ChannelNews] DROP CONSTRAINT [FK_ChannelNews_News];
GO
IF OBJECT_ID(N'[dbo].[FK_ActionRelo_Action]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ActionRelo] DROP CONSTRAINT [FK_ActionRelo_Action];
GO
IF OBJECT_ID(N'[dbo].[FK_ActionRelo_Relo]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ActionRelo] DROP CONSTRAINT [FK_ActionRelo_Relo];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[User]', 'U') IS NOT NULL
    DROP TABLE [dbo].[User];
GO
IF OBJECT_ID(N'[dbo].[Relo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Relo];
GO
IF OBJECT_ID(N'[dbo].[Action]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Action];
GO
IF OBJECT_ID(N'[dbo].[BlogArticle]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BlogArticle];
GO
IF OBJECT_ID(N'[dbo].[BlogComment]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BlogComment];
GO
IF OBJECT_ID(N'[dbo].[BlogVisit]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BlogVisit];
GO
IF OBJECT_ID(N'[dbo].[News]', 'U') IS NOT NULL
    DROP TABLE [dbo].[News];
GO
IF OBJECT_ID(N'[dbo].[Notice]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Notice];
GO
IF OBJECT_ID(N'[dbo].[Tags]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Tags];
GO
IF OBJECT_ID(N'[dbo].[Channel]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Channel];
GO
IF OBJECT_ID(N'[dbo].[WebConfig]', 'U') IS NOT NULL
    DROP TABLE [dbo].[WebConfig];
GO
IF OBJECT_ID(N'[dbo].[UserRelo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserRelo];
GO
IF OBJECT_ID(N'[dbo].[UserAction]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserAction];
GO
IF OBJECT_ID(N'[dbo].[BlogArticleTags]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BlogArticleTags];
GO
IF OBJECT_ID(N'[dbo].[ChannelNews]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ChannelNews];
GO
IF OBJECT_ID(N'[dbo].[ActionRelo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ActionRelo];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'User'
CREATE TABLE [dbo].[User] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [UserName] nvarchar(max)  NOT NULL,
    [UserPassword] nvarchar(max)  NOT NULL,
    [Email] nvarchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [QQNum] nvarchar(max)  NULL,
    [RealName] nvarchar(max)  NULL,
    [Gender] nvarchar(max)  NULL,
    [Telephone] nvarchar(max)  NULL,
    [Address] nvarchar(max)  NULL,
    [PostCode] nvarchar(max)  NULL,
    [Info] nvarchar(max)  NULL,
    [Birthday] datetime  NULL,
    [LastLoginTime] datetime  NULL,
    [LastLoginIP] nvarchar(max)  NULL,
    [IsDel] bit  NOT NULL
);
GO

-- Creating table 'Relo'
CREATE TABLE [dbo].[Relo] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Description] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Action'
CREATE TABLE [dbo].[Action] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Url] nvarchar(max)  NOT NULL,
    [rArea] nvarchar(max)  NOT NULL,
    [rController] nvarchar(max)  NOT NULL,
    [rAction] nvarchar(max)  NOT NULL,
    [rMethod] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'BlogArticle'
CREATE TABLE [dbo].[BlogArticle] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(max)  NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [WriteTime] datetime  NOT NULL,
    [Summary] nvarchar(max)  NOT NULL,
    [VisitCount] int  NOT NULL,
    [UserId] int  NOT NULL,
    [CommentCount] int  NOT NULL,
    [LastCommentTime] datetime  NULL,
    [ApprovedPass] bit  NOT NULL,
    [ApprovedInfo] nvarchar(max)  NULL,
    [image] nvarchar(max)  NULL
);
GO

-- Creating table 'BlogComment'
CREATE TABLE [dbo].[BlogComment] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [ReplyTime] datetime  NOT NULL,
    [BlogArticleId] int  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'BlogVisit'
CREATE TABLE [dbo].[BlogVisit] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [IPAddress] nvarchar(max)  NOT NULL,
    [BlogArticleId] int  NOT NULL
);
GO

-- Creating table 'News'
CREATE TABLE [dbo].[News] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(max)  NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [Keyword] nvarchar(max)  NULL,
    [Img] nvarchar(max)  NULL,
    [IsTop] bit  NOT NULL,
    [IsMoveImg] bit  NOT NULL,
    [IsImgShow] bit  NOT NULL,
    [Click] int  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'Notice'
CREATE TABLE [dbo].[Notice] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(max)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [UserId] int  NOT NULL
);
GO

-- Creating table 'Tags'
CREATE TABLE [dbo].[Tags] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [TagName] nvarchar(max)  NOT NULL,
    [TagBlogCount] int  NOT NULL
);
GO

-- Creating table 'Channel'
CREATE TABLE [dbo].[Channel] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Link] nvarchar(max)  NULL,
    [Description] nvarchar(max)  NULL,
    [Content] nvarchar(max)  NULL,
    [IsPage] bit  NOT NULL,
    [ParentId] int  NULL,
    [Seq] int  NOT NULL,
    [IsDel] bit  NOT NULL,
    [CreateTime] datetime  NOT NULL
);
GO

-- Creating table 'WebConfig'
CREATE TABLE [dbo].[WebConfig] (
    [Title] nvarchar(max)  NULL,
    [Description] nvarchar(max)  NULL,
    [Copyright] nvarchar(max)  NULL,
    [Url] nvarchar(max)  NULL,
    [Address] nvarchar(max)  NULL,
    [UpdateTime] datetime  NULL,
    [Telephone] nvarchar(max)  NULL,
    [Version] nvarchar(max)  NULL,
    [Statistics] nvarchar(max)  NULL,
    [Author] nvarchar(max)  NULL,
    [RecordCode] nvarchar(max)  NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'UserRelo'
CREATE TABLE [dbo].[UserRelo] (
    [User_Id] int  NOT NULL,
    [Relo_Id] int  NOT NULL
);
GO

-- Creating table 'UserAction'
CREATE TABLE [dbo].[UserAction] (
    [User_Id] int  NOT NULL,
    [Action_Id] int  NOT NULL
);
GO

-- Creating table 'BlogArticleTags'
CREATE TABLE [dbo].[BlogArticleTags] (
    [BlogArticle_Id] int  NOT NULL,
    [Tags_Id] int  NOT NULL
);
GO

-- Creating table 'ChannelNews'
CREATE TABLE [dbo].[ChannelNews] (
    [Channel_Id] int  NOT NULL,
    [News_Id] int  NOT NULL
);
GO

-- Creating table 'ActionRelo'
CREATE TABLE [dbo].[ActionRelo] (
    [Action_Id] int  NOT NULL,
    [Relo_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'User'
ALTER TABLE [dbo].[User]
ADD CONSTRAINT [PK_User]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Relo'
ALTER TABLE [dbo].[Relo]
ADD CONSTRAINT [PK_Relo]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Action'
ALTER TABLE [dbo].[Action]
ADD CONSTRAINT [PK_Action]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'BlogArticle'
ALTER TABLE [dbo].[BlogArticle]
ADD CONSTRAINT [PK_BlogArticle]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'BlogComment'
ALTER TABLE [dbo].[BlogComment]
ADD CONSTRAINT [PK_BlogComment]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'BlogVisit'
ALTER TABLE [dbo].[BlogVisit]
ADD CONSTRAINT [PK_BlogVisit]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'News'
ALTER TABLE [dbo].[News]
ADD CONSTRAINT [PK_News]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Notice'
ALTER TABLE [dbo].[Notice]
ADD CONSTRAINT [PK_Notice]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Tags'
ALTER TABLE [dbo].[Tags]
ADD CONSTRAINT [PK_Tags]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Channel'
ALTER TABLE [dbo].[Channel]
ADD CONSTRAINT [PK_Channel]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'WebConfig'
ALTER TABLE [dbo].[WebConfig]
ADD CONSTRAINT [PK_WebConfig]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [User_Id], [Relo_Id] in table 'UserRelo'
ALTER TABLE [dbo].[UserRelo]
ADD CONSTRAINT [PK_UserRelo]
    PRIMARY KEY CLUSTERED ([User_Id], [Relo_Id] ASC);
GO

-- Creating primary key on [User_Id], [Action_Id] in table 'UserAction'
ALTER TABLE [dbo].[UserAction]
ADD CONSTRAINT [PK_UserAction]
    PRIMARY KEY CLUSTERED ([User_Id], [Action_Id] ASC);
GO

-- Creating primary key on [BlogArticle_Id], [Tags_Id] in table 'BlogArticleTags'
ALTER TABLE [dbo].[BlogArticleTags]
ADD CONSTRAINT [PK_BlogArticleTags]
    PRIMARY KEY CLUSTERED ([BlogArticle_Id], [Tags_Id] ASC);
GO

-- Creating primary key on [Channel_Id], [News_Id] in table 'ChannelNews'
ALTER TABLE [dbo].[ChannelNews]
ADD CONSTRAINT [PK_ChannelNews]
    PRIMARY KEY CLUSTERED ([Channel_Id], [News_Id] ASC);
GO

-- Creating primary key on [Action_Id], [Relo_Id] in table 'ActionRelo'
ALTER TABLE [dbo].[ActionRelo]
ADD CONSTRAINT [PK_ActionRelo]
    PRIMARY KEY CLUSTERED ([Action_Id], [Relo_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [User_Id] in table 'UserRelo'
ALTER TABLE [dbo].[UserRelo]
ADD CONSTRAINT [FK_UserRelo_User]
    FOREIGN KEY ([User_Id])
    REFERENCES [dbo].[User]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Relo_Id] in table 'UserRelo'
ALTER TABLE [dbo].[UserRelo]
ADD CONSTRAINT [FK_UserRelo_Relo]
    FOREIGN KEY ([Relo_Id])
    REFERENCES [dbo].[Relo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserRelo_Relo'
CREATE INDEX [IX_FK_UserRelo_Relo]
ON [dbo].[UserRelo]
    ([Relo_Id]);
GO

-- Creating foreign key on [User_Id] in table 'UserAction'
ALTER TABLE [dbo].[UserAction]
ADD CONSTRAINT [FK_UserAction_User]
    FOREIGN KEY ([User_Id])
    REFERENCES [dbo].[User]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Action_Id] in table 'UserAction'
ALTER TABLE [dbo].[UserAction]
ADD CONSTRAINT [FK_UserAction_Action]
    FOREIGN KEY ([Action_Id])
    REFERENCES [dbo].[Action]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserAction_Action'
CREATE INDEX [IX_FK_UserAction_Action]
ON [dbo].[UserAction]
    ([Action_Id]);
GO

-- Creating foreign key on [BlogArticleId] in table 'BlogComment'
ALTER TABLE [dbo].[BlogComment]
ADD CONSTRAINT [FK_BlogArticleBlogComment]
    FOREIGN KEY ([BlogArticleId])
    REFERENCES [dbo].[BlogArticle]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_BlogArticleBlogComment'
CREATE INDEX [IX_FK_BlogArticleBlogComment]
ON [dbo].[BlogComment]
    ([BlogArticleId]);
GO

-- Creating foreign key on [BlogArticleId] in table 'BlogVisit'
ALTER TABLE [dbo].[BlogVisit]
ADD CONSTRAINT [FK_BlogArticleBlogVisit]
    FOREIGN KEY ([BlogArticleId])
    REFERENCES [dbo].[BlogArticle]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_BlogArticleBlogVisit'
CREATE INDEX [IX_FK_BlogArticleBlogVisit]
ON [dbo].[BlogVisit]
    ([BlogArticleId]);
GO

-- Creating foreign key on [UserId] in table 'BlogArticle'
ALTER TABLE [dbo].[BlogArticle]
ADD CONSTRAINT [FK_UserBlogArticle]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[User]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserBlogArticle'
CREATE INDEX [IX_FK_UserBlogArticle]
ON [dbo].[BlogArticle]
    ([UserId]);
GO

-- Creating foreign key on [UserId] in table 'BlogComment'
ALTER TABLE [dbo].[BlogComment]
ADD CONSTRAINT [FK_UserBlogComment]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[User]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserBlogComment'
CREATE INDEX [IX_FK_UserBlogComment]
ON [dbo].[BlogComment]
    ([UserId]);
GO

-- Creating foreign key on [UserId] in table 'News'
ALTER TABLE [dbo].[News]
ADD CONSTRAINT [FK_UserNews]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[User]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserNews'
CREATE INDEX [IX_FK_UserNews]
ON [dbo].[News]
    ([UserId]);
GO

-- Creating foreign key on [UserId] in table 'Notice'
ALTER TABLE [dbo].[Notice]
ADD CONSTRAINT [FK_UserNotice]
    FOREIGN KEY ([UserId])
    REFERENCES [dbo].[User]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_UserNotice'
CREATE INDEX [IX_FK_UserNotice]
ON [dbo].[Notice]
    ([UserId]);
GO

-- Creating foreign key on [BlogArticle_Id] in table 'BlogArticleTags'
ALTER TABLE [dbo].[BlogArticleTags]
ADD CONSTRAINT [FK_BlogArticleTags_BlogArticle]
    FOREIGN KEY ([BlogArticle_Id])
    REFERENCES [dbo].[BlogArticle]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Tags_Id] in table 'BlogArticleTags'
ALTER TABLE [dbo].[BlogArticleTags]
ADD CONSTRAINT [FK_BlogArticleTags_Tags]
    FOREIGN KEY ([Tags_Id])
    REFERENCES [dbo].[Tags]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_BlogArticleTags_Tags'
CREATE INDEX [IX_FK_BlogArticleTags_Tags]
ON [dbo].[BlogArticleTags]
    ([Tags_Id]);
GO

-- Creating foreign key on [Channel_Id] in table 'ChannelNews'
ALTER TABLE [dbo].[ChannelNews]
ADD CONSTRAINT [FK_ChannelNews_Channel]
    FOREIGN KEY ([Channel_Id])
    REFERENCES [dbo].[Channel]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [News_Id] in table 'ChannelNews'
ALTER TABLE [dbo].[ChannelNews]
ADD CONSTRAINT [FK_ChannelNews_News]
    FOREIGN KEY ([News_Id])
    REFERENCES [dbo].[News]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ChannelNews_News'
CREATE INDEX [IX_FK_ChannelNews_News]
ON [dbo].[ChannelNews]
    ([News_Id]);
GO

-- Creating foreign key on [Action_Id] in table 'ActionRelo'
ALTER TABLE [dbo].[ActionRelo]
ADD CONSTRAINT [FK_ActionRelo_Action]
    FOREIGN KEY ([Action_Id])
    REFERENCES [dbo].[Action]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Relo_Id] in table 'ActionRelo'
ALTER TABLE [dbo].[ActionRelo]
ADD CONSTRAINT [FK_ActionRelo_Relo]
    FOREIGN KEY ([Relo_Id])
    REFERENCES [dbo].[Relo]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ActionRelo_Relo'
CREATE INDEX [IX_FK_ActionRelo_Relo]
ON [dbo].[ActionRelo]
    ([Relo_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------